
<template>
  <div class="shop-item">
        <div class="item-selector">
          <check-button :is-checked="product.checked" @click.native="checkClick"></check-button>
        </div>
    <div class="item-img">
      <img :src="product.image" alt="">
    </div>
    <div class="item-info">
      <div class="item-title">{{product.title}}</div>
      <div class="item-desc">{{product.desc}}</div>
      <div class="info-bottom">
        <span class="item-price">{{'￥'+product.price}}</span>
        <span class="item-count">{{'x'+product.count}}</span>
      </div>
    </div>

  </div>
</template>

<script>
  import CheckButton from "./CheckButton";

  export default {
    name: "CartListItem",
    components: {CheckButton},
    props: {
      product: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    methods:{
      checkClick(){
        this.product.checked = !this.product.checked
      }
    }
  }
</script>

<style scoped>
  .shop-item {
    height: 125px;
    position: relative;
    width: 100%;
    /*background-color: #5ea732;*/
    overflow: hidden;
    margin: 3px 2px;
    display: flex;
    align-items: center;
    border-radius: 15px;
    border: 2px solid #e6e6e6;
    padding: 0 5px;
  }

  .item-img img {
    height: 100px;
    width: 100px;
    border-radius: 10px;
  }
  .item-info{
    margin-left: 10px;
  }
  .item-title{
    font-weight: 700;
    font-size: 17px;
  }
  .item-title, .item-desc {
    width: 50%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  .info-bottom{
      margin-top: 30px;
  }
  .item-price{
    font-size: 25px;
    font-weight: 700;
    color: #ff5777;

  }
  .item-count{
    position: absolute;
    right: 30px;
    bottom: 18px;
    height: 25px;
    width: 25px;
    border: 1px solid #666666;
    line-height: 25px;
    text-align: center;
    border-radius: 5px;
  }
</style>